﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Media;
using System.IO;
using WindowsMedia;

namespace WindowsMedia
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void playButton_Click(object sender, EventArgs e)
        {
            string url = string.Empty;

            try
            {
                url = urlTextBox.Text;
                setPlayerURL(url);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void setPlayerURL(string url)
        {
            try
            {
                wmpObject.URL = url;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        public static void playStream()
        {
            WebClient client = new WebClient();
            Stream stream = client.OpenRead("http://www.stevegrater.com/audio/test2.wav");
            SoundPlayer player = new SoundPlayer(stream);
            player.Play();  
            //stream.Close();            
        }

        private void wmpObject_ErrorEvent(object sender, EventArgs e)
        {
            //MessageBox.Show(wmpObject.Error.ToString());
        }
    }
}
